


//
//  NameListViewController.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/31.
//  Copyright © 2016年 Gcx. All rights reserved.
//

#import "NameListViewController.h"
#import "ClassManagerModel.h"
#import "NameListTableView.h"
#import "AddStudentViewController.h"

@interface NameListViewController(){

    ClassManagerModel   *_myModel;
    UILabel             *_nameLabel;
    UILabel             *_timeLabel;
    NameListTableView   *_nameTab;
}

@end

@implementation NameListViewController

- (void)viewDidLoad{

    [super viewDidLoad];
    
    [self.navbar setTitle:@"学生名单"];
    
    self.view.backgroundColor = BGC;
    
    [self addRightBtn];
    
    [self creatTopView];
}

- (void)addRightBtn{

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 20, 20);
    [btn setImage:[UIImage imageNamed:@"添加学生icon"] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(addPersonBtnClicked:) forControlEvents:UIControlEventTouchUpInside];

    [self.navbar setRightBtn:btn];
    
}

- (void)addPersonBtnClicked:(UIButton *)sender{

    AddStudentViewController *add = [[AddStudentViewController alloc]getNameListKcid:_myModel.kcid];
    
    add.hidesBottomBarWhenPushed = YES;
    
    [self navigationCanDragBack:YES];
    
    add.myBlock = ^(void){
    
        [_nameTab reset];
    };
    
    [self.navigationController pushViewController:add animated:YES];
}



- (id)initDataWithClassManagerModel:(ClassManagerModel *)model{

    _myModel = model;
    
    return self;
}


- (void)creatTopView{

    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, SIZEWIDTH, 64)];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];
    
    _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(16, 0, 190, 64)];
    _nameLabel.textColor = Color333333;
    _nameLabel.font = NormalFont(42);
    _nameLabel.textAlignment = NSTextAlignmentLeft;
    _nameLabel.text = _myModel.kcmc;
    
    _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_nameLabel.frame), 0, SIZEWIDTH-214, 64)];
    _timeLabel.textColor = Color999999;
    _timeLabel.font = NormalFont(42);
    _timeLabel.textAlignment = NSTextAlignmentRight;
    _timeLabel.text = _myModel.skxq;
    
    [topView addSubview:_nameLabel];
    [topView addSubview:_timeLabel];
    
     _nameTab = [[NameListTableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(topView.frame)+9, SIZEWIDTH, SIZEHEIGHT - 137) style:UITableViewStyleGrouped];
    _nameTab.classManagerModel = _myModel;
    [self.view addSubview:_nameTab];

}

@end
